<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>知识荟</title>
    <link rel="stylesheet" href="../css/spaces-discuss-main.css" />
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/space-discuss-main.js"></script>

</head>

<body>
<!--**************顶部导航****************-->
<%@include file="../jsp/common/nav.jsp"%>
<!--**************左侧导航****************-->
<%@include file="../jsp/common/sidebar-scroll.jsp"%>
<!--***************右侧讨论区主界面*******************-->
<c:set var="user" value="${sessionScope.user}"/>
<c:set var="space" value="${sessionScope.space}"/>
<div class="right">
    <!--标题导航-->
    <div class="discuss-nav">
        <span class="discuss-nav-title"><a href="/index/main?id=${user.id}">学习空间</a></span>
        >
        <span class="discuss-nav-title"><a href="/index/space-main?space_id=${space.id}&name=${space.name}">${space.name}</a></span>
        >
        <span>讨论区</span>
    </div>
    <!--讨论区选择-->
    <div class="tab">
        <!--全部标签-->
        <div>
            <input type="radio" id="r-1" name="tab" checked>
            <label for="r-1" class="label-1">全部</label>
            <div class="mod-1">
                <div class="top">
                    <div class="search">
                        <form action="/discuss/goToSearch" method="post">
                            <input type="text" name="title" class="title" size="105" style="height:30px;" />
                            <input type="submit" name="submit" value="搜索" class="sou"/>
                        </form>
                        <div class="dh">
                            <select onchange="self.location.href=options[selectedIndex].value">
                                <option value="#" hidden>排序方式</option>
                                <option value="${pageContext.request.contextPath}/discuss/space-discuss">排序方式</option>
                                <option value="${pageContext.request.contextPath}/discuss/descCreateDate" <c:if test="${sort==created}">selected</c:if>>
                                    创建时间
                                </option>
                                <option value="${pageContext.request.contextPath}/discuss/descUpdateDate" <c:if test="${sort==updated}">selected</c:if>>
                                    更新时间
                                </option>
                            </select>
                        </div>
                    </div>
                    <ul>
                        <c:forEach items="${discussesList}" var="discuss">
                            <li>
                                <div class="items">
                                    <div class="item-title">
                                        <a href="/discuss/discuss-detail?id=${discuss.id}&publisher_id=${discuss.user.id}">
                                            <c:if test="${discuss.status==2||discuss.status==4}">
                                                <span class="item-title-left">
                                                    <font color="red">${discuss.title}</font>
                                                </span>
                                            </c:if>
                                            <c:if test="${discuss.status==1||discuss.status==3}">
                                                <span class="item-title-left">
                                                        ${discuss.title}
                                                </span>
                                            </c:if>
                                        </a>
                                        <!--中间表的过渡判断-->
                                        <c:forEach items="${discussItemList}" var="discussItem">
                                            <c:if test="${discuss.id==discussItem.discuss_id}">
                                                <!--显示标签-->
                                                <c:forEach items="${labelList}" var="label">
                                                    <c:if test="${discussItem.label_id==label.id}">
                                                        <div class="context-label"><a>${label.name}</a></div>
                                                    </c:if>
                                                </c:forEach>
                                            </c:if>
                                        </c:forEach>
                                    </div>
                                    <div class="item-writer">
                                        <a href="/users/user-dongtai?id=${discuss.user.id}">${discuss.user.username}</a>
                                        <span class="createTime">
                                            创建于:<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
                                                                value="${discuss.createdate}"/>

                                        </span>
                                    </div>
                                </div>
                                <span class="time">
                                        更新于：<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
                                                            value="${discuss.updateDate}" />
                                </span>
                            </li>
                        </c:forEach>
                    </ul>
                </div>
            </div>
            <!--精华标签-->
            <div>
                <input type="radio" id="r-2" name="tab">
                <label for="r-2" class="label-2">精华</label>
                <div class="mod-2">
                    <div class="top">
                        <div class="search">
                            <form action="/discuss/goToSearch" method="post">
                                <input type="text" name="title" class="title" size="105" style="height:30px;"/>
                                <input type="submit" name="submit" value="搜索" class="sou" />
                            </form>
                            <div class="dh">
                                <select onchange="javascript:location.href=this.value;">
                                    <option value="${pageContext.request.contextPath}/discuss/space-discuss">排序方式</option>
                                    <option value="${pageContext.request.contextPath}/discuss/descCreateDate">
                                        创建时间
                                    </option>
                                    <option value="${pageContext.request.contextPath}/discuss/descUpdateDate">
                                        更新时间
                                    </option>
                                </select>
                            </div>
                        </div>
                        <ul>
                            <c:forEach items="${discussesList2}" var="discuss">
                                <li>
                                    <div class="items">
                                        <div class="item-title">
                                            <a href="/discuss/discuss-detail?id=${discuss.id}">
                                                <c:choose>
                                                    <c:when test="${discuss.status==2}">
                                                    <span class="item-title-left">
                                                        <font color="red">${discuss.title}</font>
                                                    </span>
                                                    </c:when>
                                                    <c:when test="${discuss.status==4}">
                                                    <span class="item-title-left">
                                                        <font color="red">${discuss.title}</font>
                                                    </span>
                                                    </c:when>
                                                    <c:otherwise>
                                                    <span class="item-title-left">
                                                        ${discuss.title}
                                                    </span>
                                                    </c:otherwise>
                                                </c:choose>
                                            </a>
                                            <!--中间表的过渡判断-->
                                            <c:forEach items="${discussItemList}" var="discussItem">
                                                <c:if test="${discuss.id==discussItem.discuss_id}">
                                                    <!--显示标签-->
                                                    <c:forEach items="${labelList}" var="label">
                                                        <c:if test="${discussItem.label_id==label.id}">
                                                            <div class="context-label"><a>${label.name}</a></div>
                                                        </c:if>
                                                    </c:forEach>
                                                </c:if>
                                            </c:forEach>
                                        </div>
                                        <div class="item-writer">
                                            <a href="/users/user-dongtai?id=${discuss.user.id}">${discuss.user.username}</a>
                                            <span class="createTime">
                                            创建于:<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
                                                                value="${discuss.createdate}"/>

                                        </span>
                                        </div>
                                    </div>
                                    <span class="time">
                                            更新于：<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${discuss.updateDate}" />
                                     </span>
                                </li>
                            </c:forEach>
                            <!--当查询结果没有时，给用户提示信息： -->
                            <li>
                                <center><font color="gray" size="2">${requestScope.msg2}</font></center>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <!--收藏标签-->
            <div>
                <input type="radio" id="r-3" name="tab">
                <label for="r-3" class="label-3">收藏</label>
                <div class="mod-3">
                    <div class="top">
                        <div class="search">
                            <form action="/discuss/goToSearch" method="post">
                                <input type="text" name="title" class="title" size="105" style="height:30px;"/>
                                <input type="submit" name="submit" value="搜索" class="sou" />
                            </form>
                            <div class="dh">
                                <select onchange="javascript:location.href=this.value;">
                                    <option value="${pageContext.request.contextPath}/discuss/space-discuss">排序方式</option>
                                    <option value="${pageContext.request.contextPath}/discuss/descCreateDate">
                                        创建时间
                                    </option>
                                    <option value="${pageContext.request.contextPath}/discuss/descUpdateDate">
                                        更新时间
                                    </option>
                                </select>
                            </div>
                        </div>
                        <ul>
                            <c:forEach items="${discussesList3}" var="discuss">
                                <li>
                                    <div class="items">
                                        <div class="item-title">
                                            <a href="/discuss/discuss-detail?id=${discuss.id}">
                                                <c:if test="${discuss.status==4}">
                                                    <span class="item-title-left">
                                                    <font color="red">${discuss.title}</font>
                                                    </span>
                                                </c:if>
                                                <c:if test="${discuss.status!=4}">
                                                <span class="item-title-left">
                                                    ${discuss.title}
                                                </span>
                                                </c:if>
                                            </a>
                                            <!--中间表的过渡判断-->
                                            <c:forEach items="${discussItemList}" var="discussItem">
                                                <c:if test="${discuss.id==discussItem.discuss_id}">
                                                    <!--显示标签-->
                                                    <c:forEach items="${labelList}" var="label">
                                                        <c:if test="${discussItem.label_id==label.id}">
                                                            <div class="context-label"><a>${label.name}</a></div>
                                                        </c:if>
                                                    </c:forEach>
                                                </c:if>
                                            </c:forEach>
                                        </div>
                                        <div class="item-writer">
                                            <a href="/users/user-dongtai?id=${discuss.user.id}">${discuss.user.username}</a>
                                            <span class="createTime">
                                                创建于:<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
                                                                    value="${discuss.createdate}"/>

                                            </span>
                                        </div>
                                    </div>
                                    <span class="time">
                                        更新于：<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
                                                            value="${discuss.updateDate}" />
                                         </span>
                                </li>
                            </c:forEach>
                            <!--当查询结果没有时，给用户提示信息： -->
                            <li>
                                <center><font color="gray" size="2">${requestScope.msg3}</font></center>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <!--发起话题-->
            <div id="button" >
                <a href="/discuss/space-discuss-send">发起话题</a>
            </div>
        </div>
    </div>
    <!--***************分页****************-->
    <div class="page">
        <ul>
            <li class="page_li">
                <a class="page_btn"id="prePage" href="${pageContext.request.contextPath}/discuss/space-discuss?page=${currentPage-1}">
                    <
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn1" href="${pageContext.request.contextPath}/discuss/space-discuss?page=1">
                    1
                </a>
            </li>
            <li class="page_li"> <span class="pages_span" id="prePoint">...</span> </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn2" href="${pageContext.request.contextPath}/discuss/space-discuss?page=${currentPage-2}">
                    ${currentPage-2}
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn3" href="${pageContext.request.contextPath}/discuss/space-discuss?page=${currentPage-1}">
                    ${currentPage-1}
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn4" href="${pageContext.request.contextPath}/discuss/space-discuss?page=${currentPage}">
                    ${currentPage}
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn5" href="${pageContext.request.contextPath}/discuss/space-discuss?page=${currentPage+1}">
                    ${currentPage+1}
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn6" href="${pageContext.request.contextPath}/discuss/space-discuss?page=${currentPage+2}">
                    ${currentPage+2}
                </a>
            </li>
            <li class="page_li"> <span class="pages_span" id="sufPoint">...</span> </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn7" href="${pageContext.request.contextPath}/discuss/space-discuss?page=${pageTotal}">
                    ${pageTotal}
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="sufPage" href="${pageContext.request.contextPath}/discuss/space-discuss?page=${currentPage+1}">
                    >
                </a>
            </li>
        </ul>
    </div>
</div>
</body>
</html>

